<template>
	<view class="member-parent">
		<scroll-view scroll-y="true">
			<view style="width: 100%;display: flex;flex-direction: column;box-sizing: border-box;">
				<view v-if="userData" class="member-top-card">
					<view class="member-content-view">
						<image class="member-head" :src="userData.avatar"></image>
						<view style="flex: 1;display: flex;flex-direction: column; padding-left: 22rpx;">
							<text class="member-name">{{userData.name}}</text>
							<text v-if="memberData.vip_name=='普通会员'" class="member-statue">普通用户</text>
							<text v-else class="member-statue" style="color: rgba(239, 196, 142, 1);">超级VIP终身版</text>
						</view>
						<view class="btn-view">
							<image v-if="memberData.vip_name=='普通会员'" class="member-open-btn"
							src="../../static/ifms_top_card_open.png" mode="scaleToFill"  @click="buyMemberShip"/>
							<image v-if="memberData.vip_name=='普通会员'" class="member-duihuan-btn"
							src="../../static/ifms_top_card_duihuan.png" mode="scaleToFill"  @click="duihuanMemberShip"/>
						</view>
					</view>
					<image class="member-desc"
					 src="../../static/ifms_top_card_text.png" mode="scaleToFill"></image>
				</view>
				<view class="member-pmd-content-view">
					<image class="member-laba" src="../../static/ic_gray_laba.png" mode="aspectFill"></image>
					<!-- 跑马灯 -->
					<swiper class="member-swiper"
							autoplay="true" 
							interval="2500" 
							circular="true"
							vertical="true"
							duration="1500"	>
							<swiper-item v-for="(item , index) in inviteSlide" :key="'swiper'+index">
								<text class="member-swiper-txt">系统通知：{{item.message}}</text>
							</swiper-item>
					</swiper>
				</view>
				<view class="member-line"></view>
				<view class="member-vip-desc-title">开通超级VIP后<text class="member-vip-desc-title1">可获得如下特权</text></view>
				<view class="member-vip-desc-list">
					<view class="member-vip-desc-item">
						<image class="member-vip-desc-item-image" src="../../static/ifms_tq_sr.png" mode="scaleToFill"></image>
						<text class="member-vip-desc-item-txt">生日特权</text>
					</view>
					<view class="member-vip-desc-item">
						<image class="member-vip-desc-item-image" src="../../static/ifms_tq_hl.png" mode="scaleToFill"></image>
						<text class="member-vip-desc-item-txt" >积分好礼</text>
					</view>
					<view class="member-vip-desc-item">
						<image class="member-vip-desc-item-image" src="../../static/ifms_tq_hd.png" mode="scaleToFill"></image>
						<text class="member-vip-desc-item-txt">专属活动</text>
					</view>
					<view class="member-vip-desc-item">
						<image class="member-vip-desc-item-image" src="../../static/ifms_tq_bs.png" mode="scaleToFill"></image>
						<text class="member-vip-desc-item-txt">标识特权</text>
					</view>
				</view>
				<view class="member-vip-desc-list">
					<view class="member-vip-desc-item">
						<image class="member-vip-desc-item-image" src="../../static/ifms_tq_cp.png" mode="scaleToFill"></image>
						<text class="member-vip-desc-item-txt">册谱特权</text>
					</view>
					<view class="member-vip-desc-item">
						<image class="member-vip-desc-item-image" src="../../static/ifms_tq_sp.png" mode="scaleToFill"></image>
						<text class="member-vip-desc-item-txt">树谱特权</text>
					</view>
					<view class="member-vip-desc-item">
						<image class="member-vip-desc-item-image" src="../../static/ifms_tq_hy.png" mode="scaleToFill"></image>
						<text class="member-vip-desc-item-txt">好友特权</text>
					</view>
					<view class="member-vip-desc-item">
						<image class="member-vip-desc-item-image" src="../../static/ifms_tq_ys.png" mode="scaleToFill"></image>
						<text class="member-vip-desc-item-txt">样式特权</text>
					</view>
				</view>
				<text class="member-bottom-desc">说明：所有用户均不设定家谱添加人数的上限。\n更多会员特权正在开发，敬请期待！</text>
			</view>
		</scroll-view>
		
		<view v-if="!userData" class="member-bottom-view">
			<image class="member-bottom-btn" src="../../static/ifms_bottom_card_open.png"
			 mode="scaleToFill" @click="buyMemberShip"></image>
		</view>
		<view v-else class="member-bottom-view">
			<image v-if="memberData.vip_name=='普通会员'" class="member-bottom-btn" src="../../static/ifms_bottom_card_open.png"
			 mode="scaleToFill" @click="buyMemberShip"></image>
			<image v-else class="member-bottom-btn" src="../../static/ifms_bottom_card_had_open.png"  mode="scaleToFill"></image>
		</view>
		<LoginTipDialog :isShow="isShowLoginTip" dataSource="登录查看具体信息"  @returnLoginTipDialog="returnLoginTipDialog"/>
		<exchangeMembersPop :isShow="isShowExchangeMembers" @returnExchangeMembers="returnExchangeMembers"/>
	</view>
</template>

<script>
	import request from '../index/request.js';
	import LoginTipDialog from "@/components/login-tip-dialog/login-tip-dialog.vue";
	import exchangeMembersPop from "@/components/exchange-members-pop/exchange-members-pop.vue";
	export default {
		components: {
			LoginTipDialog,exchangeMembersPop
		},
		data() {
			return {
				userData:null,
				memberData:null,
				inviteSlide:[],
				isShowLoginTip:false,
				isShowExchangeMembers:false,
			}
		},
		methods: {
			returnLoginTipDialog:function(e){
				this.isShowLoginTip=e.isclose
				if(e.tag){
					uni.navigateTo({
						url:"../index/index"
					})
				}
			},
			onLoad:function(options){
				this.appUtil.saveAppInviteId(options)
			},
			onShow:function(){
				var that=this
				var user = uni.getStorageSync("shiqin-user")
				this.share.url='/pages/tabBar/home/index?appInviteId='+this.appUtil.getAppInviteId()
				this.share.shareType=1
				if(user.PQD){
					this.getUserData()
					this.getMemberData()
					this.recommendList()
				}else{
					this.isShowLoginTip=true
				}
			},
			getUserData:function(){
				var that=this
				request.post("api/user/index",{
				}).then(data=>{
					this.userData=data;
				})
			},
			//获取数据
			getMemberData:function(){
				var that=this
				request.post("api/user/user_agency_ao",{
				}).then(data=>{
					that.memberData=data
				})
			},
			recommendList:function(){
				var that=this
				var user = uni.getStorageSync("shiqin-user")
				request.post("api/user/recommend_list",{
					nickname:user.nickname
				}).then(data=>{
					for (var i = 0; i < 40; i++) {
						that.inviteSlide.push(data[i])
					}
				})
			},
			buyMemberShip:function(){
				if(this.userData){
					uni.navigateTo({
						url:"../buy-membership/index"
					})
				}else{
					this.isShowLoginTip=true
				}
			},
			duihuanMemberShip:function(){
				this.isShowExchangeMembers=true
			},
			returnExchangeMembers:function(e){
				this.isShowExchangeMembers=e.isclose
				if(e.tag){
					var that=this
					request.post("api/user/usecoupon",{
						coupon:e.inputStr
					}).then(data=>{
						this.getUserData()
						this.getMemberData()
						this.recommendList()
					})
				}
			}
		}
	}
</script>

<style>
	@import "index.css";
</style>
